package cliente_diseno2011;

import java.awt.Image;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JLabel;
import java.awt.event.ActionEvent;

public class VistaPresidente extends JPanel {

	/**
	 * Create the panel.
	 */
	JButton btnEnviarDatos;
	JButton btnCierreDeLa;
	JButton btnInicioDeLa;
	JLabel label;
	private JButton btnNewButton;
	private JPanel panel;

	public VistaPresidente(boolean inicio, boolean cierre, boolean enviar) {

		btnInicioDeLa = new JButton("Inicio de la votaci\u00F3n");
		btnInicioDeLa.setEnabled(inicio);
		btnInicioDeLa.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			}
		});

		btnCierreDeLa = new JButton("Cierre de la votaci\u00F3n");
		btnCierreDeLa.setEnabled(cierre);
		btnEnviarDatos = new JButton("Enviar datos");
		btnEnviarDatos.setEnabled(enviar);
		JLabel lblEstado = new JLabel("Estado :");

		label = new JLabel("");

		btnNewButton = new JButton("Log out");
		
	
		
		Image gob = new ImageIcon("./src/img/presi.jpg").getImage();
		panel = new BoletaPanel(gob);
		
		
		GroupLayout groupLayout = new GroupLayout(this);
		groupLayout.setHorizontalGroup(
			groupLayout.createParallelGroup(Alignment.TRAILING)
				.addGroup(groupLayout.createSequentialGroup()
					.addContainerGap(83, Short.MAX_VALUE)
					.addComponent(btnInicioDeLa)
					.addGap(74)
					.addComponent(btnCierreDeLa)
					.addGap(78))
				.addGroup(groupLayout.createSequentialGroup()
					.addGap(99)
					.addComponent(btnEnviarDatos)
					.addGap(48)
					.addComponent(lblEstado)
					.addGap(61)
					.addComponent(label)
					.addContainerGap(152, Short.MAX_VALUE))
				.addGroup(groupLayout.createSequentialGroup()
					.addContainerGap(204, Short.MAX_VALUE)
					.addComponent(btnNewButton, GroupLayout.PREFERRED_SIZE, 105, GroupLayout.PREFERRED_SIZE)
					.addGap(184))
				.addGroup(groupLayout.createSequentialGroup()
					.addContainerGap(66, Short.MAX_VALUE)
					.addComponent(panel, GroupLayout.PREFERRED_SIZE, 430, GroupLayout.PREFERRED_SIZE)
					.addGap(40))
		);
		groupLayout.setVerticalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addContainerGap()
					.addComponent(panel, GroupLayout.PREFERRED_SIZE, 82, GroupLayout.PREFERRED_SIZE)
					.addGap(18)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(btnCierreDeLa)
						.addComponent(btnInicioDeLa))
					.addGap(36)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(btnEnviarDatos)
						.addComponent(lblEstado)
						.addComponent(label))
					.addPreferredGap(ComponentPlacement.RELATED, 67, Short.MAX_VALUE)
					.addComponent(btnNewButton, GroupLayout.PREFERRED_SIZE, 39, GroupLayout.PREFERRED_SIZE)
					.addGap(60))
		);
		setLayout(groupLayout);

	}

	public void addCerrarListener(ActionListener al) {
		btnCierreDeLa.addActionListener(al);

	}

	public void addInicioListener(ActionListener al) {
		btnInicioDeLa.addActionListener(al);

	}

	public void addEnviarListener(ActionListener al) {
		btnEnviarDatos.addActionListener(al);

	}

	public JLabel getEstado() {
		return label;
	}

	public void addLogoutListener(ActionListener al) {
		btnNewButton.addActionListener(al);

	}

	public void setInicio(boolean b) {
		btnInicioDeLa.setEnabled(b);
	}

	public void setFinal(boolean b) {
		btnCierreDeLa.setEnabled(b);
	}

	public void setEnviar(boolean b) {
		btnEnviarDatos.setEnabled(b);
	}

}
